package com.example.jinzproduct.server.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.example.commons.entity.ConsultationsDO;
import com.example.commons.utils.EhCacheUtil;
import com.example.jinzproduct.RedisUtil.RedisTime;
import com.example.jinzproduct.RedisUtil.RedisUtil;
import com.example.jinzproduct.server.DictService;
import com.example.jinzproduct.server.IndexService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class IndexServiceImpl implements IndexService {

    @Autowired
    private DictService dictService;
    @Resource
    private RedisUtil redisUtil;
    /**
     * 查询首页详情
     * @return
     */
    @Override
    public Map indexInfo() {

        Map maps1=new HashMap();
        Map<String, String> map = new HashMap<>();
        map.put("type", "108");
     Map map1=   (Map) redisUtil.get("cer_banners");
        if(map1!=null){
            return map1;
        }
        //获取轮播图信息
        List<Map> jsonArray = (List<Map>) EhCacheUtil.get("selBanners");
            if(jsonArray==null){
                List<Map> maps = dictService.selTypeNameVueNew(map);
                maps1.put("banners",maps);
                EhCacheUtil.put("selBanners" , maps);
                 jsonArray =maps;
            }

        maps1.put("banners",jsonArray);
        redisUtil.set("cer_banners",maps1, RedisTime.min30);
        return maps1;
    }
}
